/* shttpd - bug reporting
   Copyright (C) 2018 Ariadne Devos

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */

#include <sHT/bugs.h>

#include <stdio.h>
#include <stdlib.h>

__attribute__((nonnull (1)))
_Noreturn
static void
sHT_individual_bug(const char *msg)
{
	/* TODO: we should be phoning the control thread, but as there is
	   no such thing yet ...*/
	(void) dprintf(2, "sHT error: %s\n", msg);
	_Exit(1);
}

void
sHT_bug(const struct sHT_bug_option *options, int code)
{
	while ((options->code != 0) && (options->code != code))
		options++;
	sHT_individual_bug(options->msg);
}
